<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'registerSuccess.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
</head>

<script type="text/javascript">
     var reg = /^(\w){2,15}$/;
     var yuser=false;
  
   function yonghu(){
    
    var user=document.getElementById("username").value;
    var userfont=document.getElementById("userfont");
     $.post(
         "yanuser.action",
         {username:user},
         function uuser(data){
         if(user!=""&&user!=null){
         if(data.str=="false") userfont.innerHTML="此用户名已被注册";
         else {
         if(reg.test(user)){
         yuser=true;
         userfont.innerHTML="";
         }
         else{
          userfont.innerHTML="用户名需要1-15位";
         }
         }
         }
         else{
         userfont.innerHTML="用户名不能为空";
         }
         },
          "json"
         );
       }
       
       function yan(){
       if(yuser==true) return true;
       else {
       alert("请填写正确的用户名");
       return false;
       }
       
       }
  
  </script>

<body>
	<font size="6" color="red">恭喜您，注册成功。 </font>
	<br>
	<br>
	<form action="insertusername" method="post" onsubmit="return yan();">
		您所希望的昵称是：<input type="text" name="username" id="username"
			onblur="yonghu()"> <font id="userfont" color="red">*</font><br />
		<input type="hidden" value="${id}" name="hid"> <input
			type="submit" value="提交">
	</form>
</body>
</html>
